//
//  SAShopListVC.m
//  YunFu
//
//  Created by Bager on 2018/9/11.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "SAShopListVC.h"

#import "SAShopListCell.h"
#import "SAShopGoodsListVC.h"

@interface SAShopListVC ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation SAShopListVC

- (void)viewWillAppear:(BOOL)animated
{
    if (self.appearCallBack)
    {
        self.appearCallBack();
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
        
    [self createTable];
}

/**
 *  创建table
 */
- (void)createTable
{
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kPublicNavHeight) style:UITableViewStyleGrouped];
    _table.delegate = self;
    _table.dataSource = self;
    _table.showsVerticalScrollIndicator = NO;
    //        _table.backgroundColor = [UIColor redColor];
    [self.view addSubview:_table];
    
    UIView *noLine = [[UIView alloc] initWithFrame:CGRectZero];
    _table.tableFooterView = noLine;
}

#pragma mark - table协议

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 8;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SAShopListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifiers"];
    if (!cell)
    {
        cell = [[SAShopListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellIdentifiers"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    [cell.inBtn addTarget:self action:@selector(inShopClickWithBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [UIView new];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

- (void)inShopClickWithBtn:(UIButton *)btn
{
    ZTNavigationViewController *nav = (ZTNavigationViewController *)([Tools sh_viewControllerWith:self].navigationController);
    SAShopGoodsListVC *goods = [[SAShopGoodsListVC alloc] init];
    goods.hidesBottomBarWhenPushed = YES;
//    goods.jz_navigationBarHidden = YES;
    [nav pushViewController:goods animated:YES];
}

@end
